Eclipse Platform
Pre-release 3.0

org.eclipse.jface.text.source
Interface ITranslator


public interface ITranslator

A translator translates a given file into another language. The translator is also responsible to provide line mapping information for the translation and to compute which offset in an original line corresponds to a given offset in a target line.

XXX: This is work in progress and can change anytime until API for 3.0 is frozen.

Since:
3.0

Method Summary
 int backTranslateOffsetInLine(String sourceLine, String translatedLine, int offsetInTranslatedLine, String tag)
          Computes the offset in the source line that corresponds to the given offset in the translated line.
 int[] getLineMapping()
          Returns the line mapping information.
 void setTagHandlerFactory(ITagHandlerFactory tagHandlerFactory)
          Assigns an optional tag handler factory to this translator.
 String translate(Reader reader, String name)
          Reads the source from the given reader and creates translates it into another language.
 

Method Detail

translate

public String translate(Reader reader,
                        String name)
                 throws IOException
Reads the source from the given reader and creates translates it into another language. The translated source might be given the optional name.

Parameters:
reader - the reader to access the source
name - the name of the translated source or null if none
Returns:
Throws:
IOException

getLineMapping

public int[] getLineMapping()
Returns the line mapping information.

Returns:
an int array where the index corresponds to line numbers in the translation and the value is a source line number

setTagHandlerFactory

public void setTagHandlerFactory(ITagHandlerFactory tagHandlerFactory)
Assigns an optional tag handler factory to this translator.

A translator can delegate the handling of individual tags to tag handlers. The factory is responsible to provide the correct tag handlers.

Parameters:
tagHandlerFactory - a tag handler factory or null if this translator does all work itself

backTranslateOffsetInLine

public int backTranslateOffsetInLine(String sourceLine,
                                     String translatedLine,
                                     int offsetInTranslatedLine,
                                     String tag)
Computes the offset in the source line that corresponds to the given offset in the translated line.

Parameters:
translatedLine - the translated line
offsetInTranslatedLine - the offset in the translated line
tag - the tag to which the source line belongs or null if the tag is not known
Returns:
the offset in the source line or -1 if it was not possible to compute the offset

Eclipse Platform
Pre-release 3.0

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.